package com.starleague.game;

import com.starleague.common.AbstractChildVisitable;
import com.starleague.common.IChildVisitor;

public abstract class AbstractPlayer<GAME extends AbstractGame<? extends AbstractPlayer<GAME, TEAM>, TEAM>, TEAM extends AbstractTeam<GAME, ? extends AbstractPlayer<GAME, TEAM>>>
        extends AbstractChildVisitable
        implements IPlayer<GAME, TEAM>
{
    private TEAM team;
    private String name;

    protected AbstractPlayer(TEAM team,
                             String name)
    {
        this.team = team;
        this.name = name;
    }

    protected AbstractPlayer()
    {
        // For serialization
    }

    @Override
    public TEAM getTeam()
    {
        return this.team;
    }

    @Override
    public String getName()
    {
        return this.name;
    }

    protected void setName(String name)
    {
        this.name = name;
    }

    @Override
    public void accept(IChildVisitor visitor)
    {
        super.accept(visitor);
        visitor.visit("name", this.name);
    }
}
